/*-----------------------------------------------------------------------------
 * 
 *
 *-----------------------------------------------------------------------------
 */

#include "server/include/stock_server.h"
#include "server/include/stock_server_queue.h"
#include "server/include/stock_server_update_process.h"
#include "server/include/stock_server_gc.h"
#include "server/include/stock_server_command.h"



static void 
stock_server_usage()
{



}


static int 
stock_server_process_args(int argc, char *argv[]) 
{

    stock_server_usage();

    return 0;
}



int main(int argc, char *argv[]) 
{
    int     interactive = 1;
    uint8_t server_type = STOCK_SERVER_STREAM;

    (void) signal(SIGPIPE, SIG_IGN);

    if (stock_server_process_args(argc, argv) != 0) {
        return -1;
    }

    stock_server_queue_init();

    pthread_create(&stock_server_thread, NULL, stock_server, &server_type);
    pthread_create(&stock_server_update_process_thread, NULL, 
                    stock_server_update_process, NULL);
    pthread_create(&stock_server_gc_thread, NULL, stock_server_gc, NULL);

    if (interactive) {
        /*
         * Start the command loop in the current thread
         */
        stock_server_command_loop();
    } else {
        /*
         * Join with the othrer threads here so we don't exit
         */
    }

    return 0;

}

